package com.qf.servlet;

import com.qf.entity.Register;
import com.qf.service.RegisterService;
import com.qf.service.impl.RegisterServiceImpl;
import com.qf.utils.PageUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import com.alibaba.fastjson.JSON;

/**
 * @author chengqiang
 * @Create 2023-12-05-16:29
 * Description:
 */
@WebServlet(name = "registerSerlet",urlPatterns = "/registerSerlet")
public class RegisterServlet extends BaseServlet{
    private RegisterService registerService = new RegisterServiceImpl();

    public void selectRegister(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter pw = resp.getWriter();
        String rid = req.getParameter("rid");
        String dname = req.getParameter("dname");
        String startTime = req.getParameter("startTime");
        String endTime = req.getParameter("endTime");
        String currentPageNo = req.getParameter("currentPageNo");
        String pageSize = req.getParameter("pageSize");
        PageUtils<Register> pageUtils =  registerService.selectByPage(rid, dname, startTime, endTime, currentPageNo, pageSize);
        String s = JSON.toJSONString(pageUtils);
        System.out.println(s);
        pw.print(s);
        pw.flush();
        pw.close();
        // req.getRequestDispatcher("index.jsp").forward(req,resp);
        // resp.sendRedirect("");
    }


}
